package 代码记录.指定公司代码练习记录.西安.分值100分;

import java.util.Scanner;

/**
 * @author zx
 * @create 2023-06-27 16:49
 * 搞定
 */
public class 最长公共后缀 {//100 -- copy
    //100:最长公共后缀 --逆转每个求前缀(自己的想法)
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String temp = sc.nextLine();
        System.out.println(temp.substring(1,temp.length() - 1));
        String[] arr = temp.substring(1,temp.length() - 1).split(",");
        for(int i = 0;i < arr.length;i++){
            arr[i] = arr[i].substring(1,arr[i].length() - 1);
            StringBuilder sb = new StringBuilder(arr[i]);
            arr[i] = sb.reverse().toString();
        }
        String res = arr[0];
        for(int i = 1;i < arr.length;i++){
            int j = 0;
            for(;j < res.length() && j < arr[i].length();j++){
                if(arr[i].charAt(j) != res.charAt(j)){
                    break;
                }
            }
            res = res.substring(0,j);
        }
        System.out.println(res.equals("") ? "@Zero" : res);
    }
}
